﻿using UnityEngine;

public class ColorChangeCommand : ICommand
{
    private Color oldColor = Color.clear;
    private readonly Color color;
    private Material material;

    public ColorChangeCommand(Color color, Material material)
    {
        this.color = color;
        this.material = material;
    }

    public void Execute()
    {
        this.oldColor = this.material.color;
        this.material.color = this.color;
    }

    public void ReDo()
    {
        Color temp = this.material.color;
        this.material.color = this.oldColor;
        this.oldColor = temp;
    }

    public void UnDo()
    {
        Color temp = this.material.color;
        this.material.color = this.oldColor;
        this.oldColor = temp;
    }
}
